package com.fary.vo;

import com.fary.validator.CustomerValid;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.groups.Default;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
//@CustomerValid.List({
//        @CustomerValid(clientType = "holder"),
//        @CustomerValid(clientType = "recognizee")
//})
public class User {
    private Id id = new Id();
    // 名字不允许为空，并且名字的长度在2位到30位之间
    // 如果名字的长度校验不通过，那么提示错误信息
    @NotNull
    @Size(min = 2, max = 30, message = "请检查名字的长度是否有问题")
    private String name;

    // 不允许为空，并且年龄的最小值为18
    @NotNull
    @Min(18)
    @Min.List({@Min(12), @Min(13)})
    private Integer age;

    @DecimalMin("0.00001")
    private String age2;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date birthDate = new Date();

    private Date birthDate2;

    private List<String> list;

    @JsonIgnore
    private String holderDocumentType = "";

    @JsonIgnore
    private MultipartFile[] files;


    public class Id {

        private String name;

        public void setName(String name) {
            User.this.name = name;
        }

        public String getName() {
            return User.this.name;
        }
    }


    public interface UserInsert extends Default {
    }

    public interface UserUpdate extends Default {
    }
}
 